var qqcs;
var dq;
var qy;
var gth;
var fqydw;

$(function () {
    $("#main").height($(window).height()-1);
    qqcs = {};
    $.ajax({
        url: "/portal/query/query12/queryData.do",
        data: qqcs,
        type: "post",
        timeout: sys_timeout,
        dataType: "json",
        async: false,
        error: function (XMLHttpRequest, textStatus) {
        },
        success: function (respText) {
            if (checkResponse(respText)) {
                var data = respText.repData.data;
                // if (null != data) {
                dq = [];
                qy = [];
                gth = [];
                fqydw = [];
                for (var i = 0; i < data.length; i++) {
                    dq.push(data[i].dq_mc);
                    qy.push(data[i].qy_hs);
                    gth.push(data[i].gth_hs);
                    fqydw.push(data[i].fqydw_hs);
                }

               var sfJgjcDm =  respText.repData.sfJgjcDm;

                require.config({
                    paths: {
                        echarts: echarts2_dist_url
                    }
                });
                require(
                    [
                        'echarts',
                        'echarts/chart/line',
                        'echarts/chart/bar'
                    ],
                    function (ec) {
                        var myChart = ec.init(document.getElementById('main'));
                        window.onresize = function () {
                            if (myChart) {
                                myChart.resize();
                            }
                        };

                        if(sfJgjcDm=="32"||sfJgjcDm=="12"){
                            var option = {
                                tooltip : {
                                    trigger: 'axis'
                                },
                                legend: {
                                    data: ['企业户数', '个体户数', '非企业单位户数']
                                },
                                calculable : true,
                                xAxis : [
                                    {
                                        type : 'value',
                                        boundaryGap : [0, 0.01]
                                    }
                                ],
                                yAxis : [
                                    {
                                        type : 'category',
                                        data: dq
                                    }
                                ],
                                series: [
                                    {
                                        name: '企业户数',
                                        type: 'bar',
                                        barMaxWidth: 30,
                                        data: qy
                                    },
                                    {
                                        name: '个体户数',
                                        type:'bar',
                                        data: gth
                                    }
                                    ,
                                    {
                                        name: '非企业单位户数',
                                        type: 'bar',
                                        data: fqydw
                                    }
                                ]
                            };

                            myChart.setOption(option);

                        }else {

                            var option = option = {
                                    tooltip: {
                                        trigger: 'axis',
                                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                                            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                        }
                                    },
                                    legend: {
                                        data: ['企业户数', '个体户数', '非企业单位户数']
                                    },
                                    calculable: true,
                                    xAxis: [{
                                        type: 'category',
                                        data: dq
                                    }
                                    ],
                                    yAxis: [
                                        {
                                            type: 'value'
                                        }
                                    ],
                                    series: [
                                        {
                                            name: '企业户数',
                                            type: 'bar',
                                            stack: '总量',
                                            itemStyle: {normal: {label: {show: true, position: 'insideRight'}}},
                                            barMaxWidth: 30,
                                            data: qy
                                        },
                                        {
                                            name: '个体户数',
                                            type:
                                                'bar',
                                            stack:
                                                '总量',
                                            itemStyle:
                                                {
                                                    normal: {
                                                        label: {
                                                            show: true, position:
                                                                'insideRight'
                                                        }
                                                    }
                                                }
                                            ,
                                            data: gth
                                        }
                                        ,
                                        {
                                            name: '非企业单位户数',
                                            type:
                                                'bar',
                                            stack:
                                                '总量',
                                            itemStyle:
                                                {
                                                    normal: {
                                                        label: {
                                                            show: true, position:
                                                                'insideRight'
                                                        }
                                                    }
                                                }
                                            ,
                                            data: fqydw
                                        }
                                    ]
                                }
                            ;
                            myChart.setOption(option);

                        }
                    }
                );
                // }
            }
            else {
                innerToast.warn(respText.msg);
            }
        }
    });

});